﻿<div ms-controller="LIST">
    <div class="btn-add">


        <!--<button type="button" ms-if="datatype=='0'&&JHDATA.JHStatus=='0'" class="btn btn-success btn-lg" ms-click="sh()"><i class=" iconfont icon-bianji ft12 mr5"></i>审核通过</button>
        <button type="button" ms-if="datatype=='0'&&JHDATA.JHStatus=='0'" class="btn btn-danger btn-lg" ms-click="th()"><i class=" iconfont icon-shanchu ft12 mr5"></i>拒绝通过</button>-->

    </div>

    <div class="tab-filter-type">
        <div class="oh">
            <h5 class="pull-left tr">类型：</h5>
            <ul class="tab-type ft14">
                <li ms-click="SelectDataType('0')"><span class="active">我创建得</span></li>
                <li ms-click="SelectDataType('1')"><span>待审核</span></li>
                <li ms-click="SelectDataType('2')"><span>已审核</span></li>
            </ul>
        </div>
    </div>

    <div class="default-tab ft14 pt20 grid" style="margin-top:10px">

        <div id="jqxgrid" class="jqxgrid" style="border-right:0;border-left:0;"></div>

    </div>
</div>
<link rel="stylesheet" href="/ViewV5/JS/YanGrid/jqwidgets/styles/jqx.base.css" />
<link rel="stylesheet" href="/ViewV5/JS/YanGrid/jqwidgets/styles/jqx.office.css" />
<script src="/VIEWV5/JS/YanGrid/jqwidgets/jqgridall.js"></script>
<script>
    var goption = {
        columns: [
               {
                   text: '1', dataField: 'issel', columntype: 'checkbox', width: 40, editable: true, sortable: false, filterable: false, groupable: false, draggable: false, resizable: false,
                   renderer: function () {
                       return '<div style="margin-left: 10px; margin-top: 5px;"></div>';
                   },
                   rendered: function (element) {
                       $(element).jqxCheckBox({ theme: "office", width: 16, height: 16, animationShowDelay: 0, animationHideDelay: 0 });
                       // columnCheckBox = $(element);
                       $(element).on('change', function (event) {
                           var checked = event.args.checked;
                           if (checked == null || false) return;
                           var rowscount = $("#jqxgrid").jqxGrid('getdatainformation').rowscount;
                           $("#jqxgrid").jqxGrid('beginupdate');

                           if (checked) {
                               $("#jqxgrid").jqxGrid('selectallrows');
                           }
                           else if (checked == false) {
                               $("#jqxgrid").jqxGrid('clearselection');
                           }

                           for (var i = 0; i < rowscount; i++) {
                               $("#jqxgrid").jqxGrid('setcellvalue', i, 'issel', event.args.checked);
                           }

                           $("#jqxgrid").jqxGrid('endupdate');
                       });
                       return true;
                   }
               },
              { text: 'ID', dataField: 'ID', width: 120 },
              { text: '变更金额', dataField: 'BGJE', width: 120 },
              { text: '变更理由', dataField: 'BGLY' },
              { text: '发起人', dataField: 'ShenQingRen', width: 120 },
              { text: '发起时间', dataField: 'CRDate' },
              { text: '流程ID', dataField: 'intProcessStanceid', hidden: "hides" },
              { text: '明细ID', dataField: 'JHMXID', hidden: "hides" },



              {
                  text: '审核详情', dataField: 'Files', filterable: false, editable: false,
                  groupable: false, draggable: false, resizable: false, width: 100, cellsrenderer: function (row, column, value) {
                      var data = $('#jqxgrid').jqxGrid('getrowdata', row);
                      var html = "";
                      if (tempindex.datatype == "1") {
                          html = '<a href="#" onclick="tempindex.sh(\'' + row + '\')"><p class="text-error" style="display: inline;font-size: 16px;    color: blue;">审核</p></a>';
                      } else {
                          html = '<a href="#" onclick="tempindex.shxq(\'' + row + '\')"><p class="text-error" style="display: inline;font-size: 16px;    color: blue;">审核详情</p></a>';
                      }
                      var returns = ' <div style="overflow: hidden; text-overflow: ellipsis; padding-bottom: 2px; text-align: left; margin-right: 2px; margin-left: 4px; margin-top: 12px;">' + html + '</div>';
                      return returns;
                  }
              },



        ]
    };

    var tempindex = avalon.define({
        $id: "LIST",
        tmpListData: [],
        JHDATA: {},
        selids: "",
        datatype: "0",
        SelectDataType: function (type) {
            tempindex.datatype = type;
            tempindex.GetLIST();

        },
        InitWigetData: function (obj) {
            tempindex.JHDATA = model.JHDATA;
            //显示的列名
            tempindex.GetLIST();
            $(".tab-box li").each(function (i) {
                $(this).click(function () {
                    $(this).addClass("active").siblings().removeClass("active");
                    $("#wrap>div:eq(" + i + ")").show().siblings().hide();
                });
            });

        },
        shxq: function (row) {
            var data = $('#jqxgrid').jqxGrid('getrowdata', row);
            if (data.JHMXID) {
                ComFunJS.winviewform("/ViewV5/AppPage/APP_ADD_WF.html?FormCode=JHBG&MXID=" + data.JHMXID + "&ID=" + data.ID + "&PIID=" + data.intProcessStanceid + "&r=" + Math.random(), "修改", "1000");
            } else {
                ComFunJS.winviewform("/ViewV5/AppPage/APP_ADD_WF.html?FormCode=JHBG_JHBGZC&JHID=" + tempindex.JHDATA.ID+"&MXID=" + data.JHMXID + "&ID=" + data.ID + "&PIID=" + data.intProcessStanceid + "&r=" + Math.random(), "修改", "1000");
            }

            //ComFunJS.winviewform("/ViewV5/AppPage/APPVIEW.html?FormCode=JHBG&ID=" + data.ID + "&PIID=" + data.intProcessStanceid + "&r=" + Math.random(), "查看");
        },
        getcheckid: function () {
            tempindex.selids = "";
            var rowindexes = $('#jqxgrid').jqxGrid('getselectedrowindexes');
            for (var i = 0; i < rowindexes.length; i++) {
                var data = $('#jqxgrid').jqxGrid('getrowdata', rowindexes[i]);
                if (i == 0) {
                    tempindex.selids = data.ID;
                } else {
                    tempindex.selids = tempindex.selids + "," + data.ID;

                }
            }
            return tempindex.selids;
        },
        sh: function (row) {
            var data = $('#jqxgrid').jqxGrid('getrowdata', row);
            if (data.JHMXID) {
                ComFunJS.winviewform("/ViewV5/AppPage/APP_ADD_WF.html?FormCode=JHBG&MXID=" + data.JHMXID + "&ID=" + data.ID + "&PIID=" + data.intProcessStanceid + "&r=" + Math.random(), "修改", "1000");
            } else {
                ComFunJS.winviewform("/ViewV5/AppPage/APP_ADD_WF.html?FormCode=JHBG_JHBGZC&JHID=" + tempindex.JHDATA.ID + "&MXID=" + data.JHMXID + "&ID=" + data.ID + "&PIID=" + data.intProcessStanceid + "&r=" + Math.random(), "修改", "1000");

            }
        },

        GetLIST: function () {
            try {
                $('#jqxgrid').jqxGrid('destroy');

            } catch (e) {

            }
            $(".grid").append('<div id="jqxgrid" class="jqxgrid" style="border-right:0;border-left:0;"></div>')
            model.search.seartype = "";
            $.getJSON('/API/VIEWAPI.ashx?Action=JHBG_GETJHBGLIST', { P2: tempindex.JHDATA.ID, P1: tempindex.datatype }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    for (var i = 0; i < resultData.Result.length; i++) {
                        resultData.Result[i].issel = "false";
                    }
                    ComFunJS.inithighgrid(goption, resultData.Result, "jqxgrid");
                    tempindex.tmpListData = resultData.Result;
                }
            })
        }
    }) //@ sourceURL=JHBG_SHMXLIST.js;
</script>
